<template>
  <div>
    <el-button @click="resetDateFilter">清除日期过滤器</el-button>
    <el-button @click="clearFilter">清除所有过滤器</el-button>
    <el-table
      stripe
      ref="filterTable"
      :data="tableData"
      style="width: 100%"
      height="calc(100vh - 220px)"
    >
      <el-table-column
        prop="date"
        label="日期"
        sortable
        width="150"
        column-key="date"
      >
      </el-table-column>
      <el-table-column prop="name" label="姓名" width="100"> </el-table-column>
      <el-table-column prop="po" label="政治面貌" width="200"></el-table-column>
      <el-table-column prop="reason" label="申请理由" width="200"></el-table-column>

      <el-table-column
        prop="Political"
        label="申请的类型"
        width="120"
      ></el-table-column>
      <el-table-column label="相关资料" width="300"
        ><el-button type="text" size="small">查看</el-button></el-table-column
      >
      <el-table-column prop="address" label="是否同意">
        <el-button type="success" @click="open">同意</el-button>
        <el-button type="danger" @click="refuse">拒绝</el-button>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { hfApplicationSelectAll} from "@/utils/data";
export default {
  name: "MyApplication",
  data() {
    return {
      tableData: [],
    };
  },
  mounted() {
    this.getTableData()
  },
  methods: {
    getTableData(){
      hfApplicationSelectAll({}).then(res=>{
        console.log(res)
        if(res){
          this.tableData = res
          console.log(this.tableData)
        }
      }).catch(err=>{
        console.log(err)
      })
    },
    // 拒绝
    refuse() {
      this.$prompt("请输入拒绝理由", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        inputErrorMessage: "邮箱格式不正确",
      })
        .then(() => {
          this.$message({
            type: "error",
            message: "您已拒绝用户申请",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "取消输入",
          });
        });
    },
    // 同意
    open() {
      this.$confirm("是否确认, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "success",
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "确认成功!",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消",
          });
        });
    },
    resetDateFilter() {
      this.$refs.filterTable.clearFilter("date");
    },
    clearFilter() {
      this.$refs.filterTable.clearFilter();
    },
    formatter(row) {
      return row.address;
    },
    filterTag(value, row) {
      return row.tag === value;
    },
    filterHandler(value, row, column) {
      const property = column["property"];
      return row[property] === value;
    },
  },
};
</script>

<style>
</style>
